#else
static xg_callback goog_points, goog_levels, goog_poly_e, goog_script;
-static xg_callback goog_segment_s, goog_segment;
+static xg_callback goog_segment_s, goog_segment, goog_td_s, goog_td_b;
+static xg_callback goog_td_e;
static
xg_tag_mapping google_map[] = {
{ goog_script, cb_cdata, "/html/head/script" },
{ goog_segment_s, cb_start, "/page/directions/segments/segment" },
{ goog_segment, cb_cdata, "/page/directions/segments/segment" },
+ { goog_td_s, cb_start, "/div/table/tr/td" },
+ { goog_td_b, cb_cdata, "/div/table/tr/td/b" },
+ { goog_td_e, cb_end, "/div/table/tr/td" },
{ NULL, 0, NULL }
};
}
static char goog_segname[7];
+static char *goog_realname = NULL;
/*
* The segments contain an index into the points array. We use that
}
}
+void goog_td_s( const char *args, const char **attrv )
+{
+ const char **avp = &attrv[0];
+ int isdesc = 0;
+ while (*avp) {
+ if ( 0 == strcmp(avp[0], "class" )) {
+ isdesc = !strcmp(avp[1], "desc" );
+ }
+ else if ( isdesc && (0 == strcmp( avp[0], "id" ))) {
+ snprintf( goog_segname, sizeof(goog_segname),
+ "\\%5.5x",
+ atoi(avp[1] + 6 ));
+ }
+ avp += 2;
+ }
+}
+
+void goog_td_b( const char *args, const char **attrv ) {
+ if ( goog_segname[0] == '\\' && !strchr( args, '\xa0')) {
+ if ( goog_realname ) {
+ xfree( goog_realname );
+ goog_realname = NULL;
+ }
+ goog_realname = xmalloc( strlen(args)+1);
+ strcpy( goog_realname, args );
+ }
+}
+void goog_td_e( const char *args, const char **attrv )
+{
+ if ( goog_segname[0] == '\\' && goog_realname ) {
+ goog_segment( goog_realname, attrv );
+ }
+ goog_segname[0] = '\0';
+ if ( goog_realname ) {
+ xfree( goog_realname );
+ goog_realname = NULL;
+ }
+}
+
static long decode_goog64( char **str )
{
long result = 0;
if ( script )
{
char *xml = strchr( script, '\'' );
+ char *dict = strstr( script, "({" );
+
char *end = NULL;
- if ( xml ) {
+
+ if ( xml && (!dict || (xml < dict ))) {
xml++;
end = strchr( xml+1, '\'' );
if ( end ) {
xml_readstring( xml );
}
}
+ else if ( dict ) {
+ encoded_points = strstr( dict, "points: '" );
+ encoded_levels = strstr( dict, "levels: '" );
+ char *panel = strstr( dict, "panel: '" );
+
+ if ( encoded_points && encoded_levels ) {
+ encoded_points += 9;
+ encoded_levels += 9;
+ end = strchr( encoded_points, '\'' );
+ if ( end ) {
+ *end = '\0';
+ end = strchr( encoded_levels, '\'' );
+ if ( end ) {
+ *end = '\0';
+ goog_poly_e( NULL, NULL );
+ }
+ }
+ }
+ if ( panel ) {
+ panel += 8;
+ end = strstr( panel, ">'," );
+ if ( end ) {
+ *(end+1) = '\0';
+ end = panel;
+ while ( (end = strstr( end, "\\\"" ))) {
+ strcpy( end, end+1 );
+ }
+ end = panel;
+ while ( (end = strstr( end, "\\'" ))) {
+ strcpy( end, end+1 );
+ }
+ xml_deinit();
+ xml_init( NULL, google_map, NULL );
+ xml_readstring( panel );
+ }
+ }
+ }
xfree( script );
}
}
# Google Maps XML test
#
rm -f ${TMPDIR}/google.out
-${PNAME} -i google -f reference/google.xml -o arc -F ${TMPDIR}/google.out
-compare ${TMPDIR}/google.out reference/google.arc
+${PNAME} -i google -f reference/google.xml -o csv -F ${TMPDIR}/google.out
+compare ${TMPDIR}/google.out reference/google.csv
rm -f ${TMPDIR}/google.out
-${PNAME} -i google -f reference/google.js -o arc -F ${TMPDIR}/google.out
-compare ${TMPDIR}/google.out reference/google.arc
+${PNAME} -i google -f reference/google.js -o csv -F ${TMPDIR}/google.out
+compare ${TMPDIR}/google.out reference/google.csv
+
+rm -f ${TMPDIR}/google.out
+${PNAME} -i google -f reference/google_jan_06.html -o csv -F ${TMPDIR}/google.out
+compare ${TMPDIR}/google.out reference/google_jan_06.csv
#
# DeLorme .an1 tests